#include <cstdio>
#include <memory.h>

int sg[ 61 ][ 61 ];

void initsg( )
{
    int i, j, k, i2, j2;
    bool use[ 2501 ];
    for ( i = 0; i <= 50; i++ )
        sg[ i ][ 0 ] = sg[ 0 ][ i ] = i;
    for ( i = 1; i <= 50; i++ )
        for ( j = 1; j <= 50; j++ )
        {
            memset( use, 0, sizeof( use ) );
            for ( i2 = i - 1; i2 >= 0; i2-- )
                for ( j2 = j - 1; j2 >= 0; j2-- )
                    use[ sg[ i ][ j2 ] ^ sg[ i2 ][ j ] ] = 1;
            for ( i2 = 0; use[ i2 ]; i2++ );
            sg[ i ][ j ] = i2;
        }
}

int main( )
{
    int n, m, ans, i, j;
    char s[ 61 ][ 61 ];
    initsg( );
    while ( scanf("%d%d", &n, &m) == 2 )
    {
        if ( n == 0 && m == 0 ) break;
        for ( i = 0; i < n; i++ )
            scanf("%s", s[ i ]);
        ans = 0;
        for ( i = 0; i < n; i++ )
            for ( j = 0; j < m; j++ )
                if ( s[ i ][ j ] == '#' )
                    ans ^= sg[ i ][ j ];
        if ( ans )
            puts("John");
        else
            puts("Jack");
    }
    return 0;
}
